<fieldset>
    <legend>Feltöltött fájlok listája</legend>
    <table id="admin_table" border="1">
        <th id="admin_th">Név</th>
        <th id="admin_th">Kategória</th>
        <th id="admin_th" colspan="2"></th>
        <?php foreach ($categories as $cat) { ?>
        <?php $files = ORM::factory('downloads')->where('category_id', '=', $cat->id)->find_all(); ?>
        <?php foreach ($files as $file) { ?>
        <tr>
            <?php echo form::open('downloads/editfiles', array('id' => 'file_form_' . $file->id)) ?>
            <?php echo form::hidden('file_id', $file->id) ?>
        <td class="admin_td"><?php echo form::label('description', $file->description, array('id' => 'file_descriptionlabel_' . $file->id, 'onClick' => 'file_change(' . $file->id . ')')) ?>
            <?php echo form::input('description', $file->description, array('class' => 'inputclass', 'id' => 'file_input_' . $file->id)) ?></td>
            <td class="admin_td"><?php echo form::label('cat', $cat->name, array('id' => 'file_selectlabel_' . $file->id, 'onClick' => 'file_change(' . $file->id . ')')) ?>
            <select name="file_cat" class="selectclass" id="file_select_<?php echo $file->id ?>">
                <?php $cats = ORM::factory('category')->find_all(); ?>
                <?php foreach ($cats as $c) { ?>
                    <option id="<?php echo $c->id ?>" <?php if ($c->id == $file->category_id) echo 'selected'; ?>><?php echo $c->name ?></option>
                <?php } ?>
            </select></td>
            <td class="admin_td"><a href="#" onClick="file_change(<?php echo $file->id ?>)" id="file_edit_<?php echo $file->id ?>">Szerkesztés</a></td>
            <td class="admin_td"><a href="<?php echo Url::site('downloads/deletefiles', TRUE, FALSE) .'/'. $file->id ?>">Törlés</a><br/></td>
            <?php echo form::close() ?>
        </tr>
                <?php } ?>
    <?php } ?>
            </table>
</fieldset>
